list = [3, 2, 5, 7, 9, 12, 97, 24, 54]

sum_gerade = 0
sum_ungerade = 0

for i in range(len(list)):
    if list[i] < 0:#Check for invalid numbers
        raise Exception("Nur Null oder Positiv")
    
    if list[i] %2 ==0:
       sum_gerade+=list[i] 
    else:
        sum_ungerade+=list[i]
    
print sum_gerade
print sum_ungerade
